<template>
  <div>
    <!-- //头 -->
    <TodoHeader @ddd="fu"></TodoHeader>
    <!-- 体 -->
    <TodoMain :list="list" @sc="aa"></TodoMain>
    <!-- 尾 -->
    <TodoFooter :list="list" @ccdd="list = []"></TodoFooter>
  </div>
</template>
<script>
import TodoHeader from './xhjsb/Todollearder.vue'
import TodoMain from './xhjsb/TodoMain.vue'
import TodoFooter from './xhjsb/TodoFooter.vue'

export default {
  components: {
    TodoHeader,
    TodoMain,
    TodoFooter
  },
  name: '',
  data () {
    return {
      // list: [
      //   { id: 1, name: '跑步100米' },
      //   { id: 2, name: '游泳50米' },
      //   { id: 3, name: '跳绳100次' }
      // ]
      list: JSON.parse(localStorage.getItem('list')) || [
        { id: 1, name: '跑步100米' },
        { id: 2, name: '游泳50米' },
        { id: 3, name: '跳绳100次' }
      ]
    }
  },
  watch: {
    list (a) {
      localStorage.setItem('list', JSON.stringify(a))
    }
  },
  created () {
  },
  computed: {
  },
  methods: {
    fu (a) {
      this.list.push(a)
    },
    aa (id) {
      this.list = this.list.filter(item => item.id !== id)
    }
  }
}
</script>
<style lang='less'  scoped>
</style>
